package redis

import (
	"context"
	"github.com/go-redis/redis/v8"
)

func NewRedis(opt *Options) *redis.Client {
	cli := redis.NewClient(&redis.Options{
		Addr:       opt.Addr,
		Password:   opt.Password,
		DB:         opt.DB,
		MaxRetries: opt.MaxRetries,
	})
	ctx := context.Background()
	err := cli.Ping(ctx).Err()
	if err != nil {
		panic(err)
	}
	return cli
}
